package com.nbsaas.boot.manufacturing.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "工艺步骤", model = "工艺步骤")
@Entity
@Table(name = "bs_process_step")
@Comment("工艺步骤表")
public class ProcessStep extends AbstractEntity {

    @Comment("工艺路线ID")
    @FormField(title = "工艺路线", sortNum = "1", grid = true, type = InputType.select, required = true)
    private Long processRouteId;

    @Comment("步骤编号")
    @SearchItem(name = "stepNo", key = "stepNo", label = "步骤编号")
    @FormField(title = "步骤编号", sortNum = "2", grid = true, required = true)
    @Column(length = 50, nullable = false)
    private String stepNo;

    @Comment("步骤名称")
    @SearchItem(name = "name", key = "name", label = "步骤名称")
    @FormField(title = "步骤名称", sortNum = "3", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("步骤描述")
    @FormField(title = "步骤描述", sortNum = "4", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String description;

    @Comment("工序类型")
    @FormField(title = "工序类型", sortNum = "5", grid = true, type = InputType.select)
    @Column(length = 50)
    private String processType; // ASSEMBLY-装配, MACHINING-机加工, WELDING-焊接, PAINTING-喷涂, TESTING-检测

    @Comment("工作中心ID")
    @FormField(title = "工作中心", sortNum = "6", grid = true, type = InputType.select)
    private Long workCenterId;

    @Comment("设备ID")
    @FormField(title = "设备", sortNum = "7", grid = true, type = InputType.select)
    private Long equipmentId;

    @Comment("标准工时(分钟)")
    @FormField(title = "标准工时(分钟)", sortNum = "8", grid = true, type = InputType.el_input_number)
    private Integer standardTime;

    @Comment("准备时间(分钟)")
    @FormField(title = "准备时间(分钟)", sortNum = "9", grid = true, type = InputType.el_input_number)
    private Integer setupTime;

    @Comment("单位成本")
    @FormField(title = "单位成本", sortNum = "10", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal unitCost;

    @Comment("步骤顺序")
    @FormField(title = "步骤顺序", sortNum = "11", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sequence;

    @Comment("是否并行")
    @FormField(title = "是否并行", sortNum = "12", grid = true, type = InputType.select)
    private Boolean isParallel;

    @Comment("是否可选")
    @FormField(title = "是否可选", sortNum = "13", grid = true, type = InputType.select)
    private Boolean isOptional;

    @Comment("前置步骤")
    @FormField(title = "前置步骤", sortNum = "14", grid = true)
    @Column(length = 500)
    private String predecessorSteps;

    @Comment("后置步骤")
    @FormField(title = "后置步骤", sortNum = "15", grid = true)
    @Column(length = 500)
    private String successorSteps;

    @Comment("质量检查点")
    @FormField(title = "质量检查点", sortNum = "16", grid = true, type = InputType.select)
    private Boolean isQualityCheckpoint;

    @Comment("质量要求")
    @FormField(title = "质量要求", sortNum = "17", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String qualityRequirements;

    @Comment("工艺参数")
    @FormField(title = "工艺参数", sortNum = "18", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String processParameters;

    @Comment("操作指导")
    @FormField(title = "操作指导", sortNum = "19", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String operationGuide;

    @Comment("安全注意事项")
    @FormField(title = "安全注意事项", sortNum = "20", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String safetyNotes;

    @Comment("所需工具")
    @FormField(title = "所需工具", sortNum = "21", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String requiredTools;

    @Comment("所需物料")
    @FormField(title = "所需物料", sortNum = "22", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String requiredMaterials;

    @Comment("步骤状态")
    @FormField(title = "步骤状态", sortNum = "23", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // ACTIVE-启用, INACTIVE-停用

    @Comment("备注")
    @FormField(title = "备注", sortNum = "24", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 